﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SchEdu.Framework.DataModel;
using SchEdu.Framework.Validators;

namespace SchEdu.Framework.Objective
{
    class TotalWeighedFlowTime : Objective
    {
        public TotalWeighedFlowTime()
            : base()
        {
        }
        public TotalWeighedFlowTime(SchEduData schEduData, SchEduDataSet.SolutionRow solution)
            : base(schEduData, solution)
        {
        }
        protected override void Logic()
        {
            int flowTime = 0;
            int totalWeighedFlowTime = 0;

            foreach (SchEduDataSet.OrderRow order in SchEduData.Order)
            {
                flowTime = order.EndDate - order.ReleaseDate;

                totalWeighedFlowTime = totalWeighedFlowTime + (order.Weight * flowTime);
            }

        }

        protected override void InitializeValidators()
        {
            base.InitializeValidators();
            validators.Add(new OrderDueDateValidator(SchEduData));
            validators.Add(new OrderReleaseDateValidator(SchEduData));
            validators.Add(new OrderWeightValidator(SchEduData));
        }


        public override AboutInfo AboutInfo
        {
            get
            {
                AboutInfo aboutInfo = new AboutInfo();
                aboutInfo.Title = "Total Weighed Flow Time";
                aboutInfo.Guid = new Guid("{ABCE0EB1-78B0-4a8b-A265-9A5C61304288}");
                aboutInfo.Description = Resources.TotalWeighedFlowTimeDescription;
                return aboutInfo;
            }
        }

    }
}
